package com.sunda.spmswms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunda.spmswms.entity.WhsDumpDtl;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 转储任务明细表 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2021-06-29
 */
@Mapper
public interface WhsDumpDtlMapper extends BaseMapper<WhsDumpDtl> {

    @Select("SELECT ROWNUM AS \"rowId\", RE.*\n" +
            "FROM (\n" +
            "         SELECT WDD.WHS_DUMP_UUID AS \"whsDumpUuid\",\n" +
            "                WDD.ITEM AS \"item\",\n" +
            "                WDD.MATERIAL_NO AS \"materialNo\",\n" +
            "                SAP.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "                SAP.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "                WDD.BASIC_UNIT AS \"basicUnit\",\n" +
            "                WDD.BOX_NOTE AS \"boxNote\",\n" +
            "                WDD.PLANNED_OUT_QTY AS \"plannedOutQty\",\n" +
            "                WDD.PLANNED_OUT_STORAGE AS \"plannedOutStorage\",\n" +
            "                WDD.ACTUAL_OUT_QTY AS \"actualOutQty\",\n" +
            "                WDD.ACTUAL_OUT_STORAGE AS \"actualOutStorage\",\n" +
            "                WDD.DUMP_OUT_REMARK AS \"dumpOutRemark\",\n" +
            "                WDD.ACTUAL_IN_QTY AS \"actualInQty\",\n" +
            "                WDD.ACTUAL_IN_STORAGE AS \"actualInStorage\",\n" +
            "                WDD.DUMP_IN_REMARK AS \"dumpInRemark\"\n" +
            "         FROM WHS_DUMP_DTL WDD LEFT JOIN MATERIAL_SAP SAP ON WDD.MATERIAL_NO = SAP.MATERIAL_NO\n" +
            "         WHERE WDD.WHS_DUMP_UUID = #{whsDumpUuid} ORDER BY WDD.ITEM ASC\n" +
            "         ) RE ORDER BY ROWNUM ASC ")
    List<Map<String, Object>> getWhsDumpDtlList(@Param("whsDumpUuid") String whsDumpUuid);
}
